﻿<Page
    RequestedTheme="Light"
    x:Class="wToggl.WorkspacePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:wToggl"
     DataContext="{Binding RelativeSource={RelativeSource Self}}"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Page.Resources>
        <ResourceDictionary>
            <DataTemplate x:Key="HubSectionHeaderTemplate">
                <TextBlock Margin="0,0,0,-9.5" Text="{Binding}"/>
            </DataTemplate>
        </ResourceDictionary>
    </Page.Resources>

    <Page.BottomAppBar>
        <CommandBar ClosedDisplayMode="Compact">
            <CommandBar.PrimaryCommands>
                <AppBarButton Visibility="Visible" IsEnabled="True" Label="Add" Name="AddItemButton" Click="AddItemButton_OnClick" >
                    <SymbolIcon Symbol="Add"/>
                </AppBarButton>
            </CommandBar.PrimaryCommands>
        </CommandBar>
    </Page.BottomAppBar>

    <Grid x:Name="LayoutRoot">
        <local:BackgroundWorkOverlay Canvas.ZIndex="10" IsVisible="{Binding IsWorking}" OverlayMessage="{Binding OverlayMessage}"/>
        <Hub x:Name="Hub" Header="{Binding Workspace.Name}">
            <HubSection  x:Uid="HubSection1" Header="PROJECTS" HeaderTemplate="{StaticResource HubSectionHeaderTemplate}">
                <DataTemplate>
                    <ScrollViewer>
                        <Grid>
                            <ListView SelectionMode="None" ItemsSource="{Binding Projects}">
                                <ListView.ItemContainerStyle>
                                    <Style TargetType="ListViewItem">
                                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                        <Setter Property="HorizontalAlignment" Value="Stretch"/>
                                    </Style>
                                </ListView.ItemContainerStyle>
                                <ListView.ItemTemplate>
                                    <DataTemplate>
                                        <Grid IsTapEnabled="True" HorizontalAlignment="Stretch" Name="ProjectList" Tapped="ProjectList_OnTapped" Holding="ProjectList_OnHolding">
                                            <FlyoutBase.AttachedFlyout>
                                                <MenuFlyout Placement="Bottom">
                                                    <MenuFlyoutItem Text="Show details" Name="ProjectDetailsMenu"  Click="ProjectDetailsMenu_OnClick" />
                                                    <MenuFlyoutItem Text="Delete" Name="ProjectDeleteMenu" Click="ProjectDeleteMenu_OnClick"/>
                                                </MenuFlyout>
                                            </FlyoutBase.AttachedFlyout>

                                            <TextBlock Padding="0,10,0,10" HorizontalAlignment="Stretch" Text="{Binding NameWithClient}" FontSize="25"/>
                                        </Grid>
                                    </DataTemplate>
                                </ListView.ItemTemplate>
                            </ListView>
                        </Grid>
                    </ScrollViewer>
                </DataTemplate>
            </HubSection>

            <HubSection x:Uid="HubSection2" Header="CLIENTS" HeaderTemplate="{StaticResource HubSectionHeaderTemplate}">
                <DataTemplate>
                    <ScrollViewer>
                        <Grid>
                            <ListView HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" SelectionMode="None" ItemsSource="{Binding Clients}">
                                <ListView.ItemContainerStyle>
                                    <Style TargetType="ListViewItem">
                                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                        <Setter Property="HorizontalAlignment" Value="Stretch"/>
                                    </Style>
                                </ListView.ItemContainerStyle>
                                <ListView.ItemTemplate>
                                    <DataTemplate>
                                        <Grid IsTapEnabled="True" HorizontalAlignment="Stretch" Name="ProjectList" Tapped="ClientList_OnTapped" Holding="ClientList_OnHolding">
                                            <FlyoutBase.AttachedFlyout>
                                                <MenuFlyout Placement="Bottom">
                                                    <MenuFlyoutItem Text="Show details" Name="ClientDetailsMenu"  Click="ClientDetailsMenu_OnClick" />
                                                    <MenuFlyoutItem Text="Delete" Name="ClientDeleteMenu" Click="ClientDeleteMenu_OnClick"/>
                                                </MenuFlyout>
                                            </FlyoutBase.AttachedFlyout>

                                            <TextBlock Padding="0,10,0,10" HorizontalAlignment="Stretch" Text="{Binding Name}" FontSize="25"/>
                                        </Grid>
                                    </DataTemplate>
                                </ListView.ItemTemplate>
                            </ListView>
                        </Grid>
                    </ScrollViewer>
                </DataTemplate>
            </HubSection>

            <HubSection x:Uid="HubSection3" Header="TAGS" HeaderTemplate="{StaticResource HubSectionHeaderTemplate}">
                <DataTemplate>
                    <ScrollViewer>
                        <Grid>
                            <ListView SelectionMode="None" ItemsSource="{Binding Tags}">
                                <ListView.ItemContainerStyle>
                                    <Style TargetType="ListViewItem">
                                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                        <Setter Property="HorizontalAlignment" Value="Stretch"/>
                                    </Style>
                                </ListView.ItemContainerStyle>
                                <ListView.ItemTemplate>
                                    <DataTemplate>
                                        <Grid IsTapEnabled="True" HorizontalAlignment="Stretch" Name="TagList" Tapped="TagList_OnTapped" Holding="TagList_OnHolding">
                                            <FlyoutBase.AttachedFlyout>
                                                <MenuFlyout Placement="Bottom">
                                                    <MenuFlyoutItem Text="Show details" Name="TagDetailsMenu"  Click="TagDetailsMenu_OnClick" />
                                                    <MenuFlyoutItem Text="Delete" Name="TagDeleteMenu" Click="TagDeleteMenu_OnClick"/>
                                                </MenuFlyout>
                                            </FlyoutBase.AttachedFlyout>

                                            <TextBlock Padding="0,10,0,10" HorizontalAlignment="Stretch" Text="{Binding Name}" FontSize="25"/>
                                        </Grid>
                                    </DataTemplate>
                                </ListView.ItemTemplate>
                            </ListView>
                        </Grid>
                    </ScrollViewer>
                </DataTemplate>
            </HubSection>
        </Hub>
    </Grid>
</Page>
